1 using System.Collections.Generic;
2 using
UnityEngine;
3 using
System.Collections;
4 using
Hashtable = ExitGames.Client.Photon.Hashtable;
5
6 public
class PickupDemoGui : MonoBehaviour
7 {
8     
public bool ShowScores;
9     
public bool ShowDropButton;
10     
public bool ShowTeams;
11     
public float DropOffset = 0.5f;
12
13
14
15     
public void OnGUI()
16     {
17         
if (!PhotonNetwork.inRoom)
18         {
19             
return;
20         }
21
22
23         
if (this.ShowScores)
24         {
25             GUILayout.Label(
"Your Score: " + PhotonNetwork.player.GetScore());
26         }
27
28
29         
if (this.ShowDropButton)
30         {
31             
foreach (PickupItem item in PickupItem.DisabledPickupItems)
32             {
33                 
if (item.PickupIsMine && item.SecondsBeforeRespawn <= 0)
34                 {
35                     
if (GUILayout.Button("Drop " + item.name))
36                     {
37                         item.Drop();
// drops the item at the place where it originates
38                     }
39                     
40                     GameObject playerCharGo = PhotonNetwork.player.TagObject
as GameObject;
41                     
if (playerCharGo != null && GUILayout.Button("Drop here " + item.name))
42                     {
43                         
// drop the item at some other place. next to the user's character would be fine...
44                         Vector3 random = Random.insideUnitSphere;
45                         random.y =
0;
46                         random = random.normalized;
47                         Vector3 itempos = playerCharGo.transform.position +
this.DropOffset * random;
48                         
49                         item.Drop(itempos);
50                     }
51                 }
52             }
53         }
54
55
56         
if (this.ShowTeams)
57         {
58             
foreach (var teamName in PunTeams.PlayersPerTeam.Keys)
59             {
60                 GUILayout.Label(
"Team: " + teamName.ToString());
61                 List<PhotonPlayer> teamPlayers = PunTeams.PlayersPerTeam[teamName];
62                 
foreach (PhotonPlayer player in teamPlayers)
63                 {
64                     GUILayout.Label(
" " + player.ToStringFull() + " Score: " + player.GetScore());
65                 }
66             }
67
68             
if (GUILayout.Button("to red"))
69             {
70                 PhotonNetwork.player.SetTeam(PunTeams.Team.red);
71             }
72             
if (GUILayout.Button("to blue"))
73             {
74                 PhotonNetwork.player.SetTeam(PunTeams.Team.blue);
75             }
76         }
77     }
78 }


item.Drop(); drops the item at the place where it originates

drop the item at some other place. next to the user's character would be fine...




Trò chơi Tic-Tac-Toe, game đánh caro full source code 53.484 lượt xem

Gõ tìm kiếm nhanh...